home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / rpc / rpcDebug.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-12  |  17.4 KB  |  635 lines

  1. /*
  2.  * rpcDebug.c --
  3.  *
  4.  *    Debugging routines for the Rpc system.  These routines are used
  5.  *    to profile and trace the whole system.
  6.  *
  7.  * Copyright 1985 Regents of the University of California
  8.  * All rights reserved.
  9.  */
  10.  
  11. #ifndef lint
  12. static char rcsid[] = "$Header: /sprite/src/kernel/rpc/RCS/rpcDebug.c,v 9.6 91/02/12 14:15:43 jhh Exp $ SPRITE (Berkeley)";
  13. #endif /* not lint */
  14.  
  15. #include <sprite.h>
  16. #include <stdio.h>
  17. #include <status.h>
  18. #include <rpc.h>
  19. #include <rpcInt.h>
  20. #include <fs.h>
  21. #include <timer.h>
  22. #include <vm.h>
  23. #include <sync.h>
  24. #include <sched.h>
  25. #include <rpcClient.h>
  26. #include <rpcServer.h>
  27. #include <rpcTrace.h>
  28. #include <dev.h>
  29. #include <user/sysStats.h>
  30.  
  31. #include <fsio.h>
  32.  
  33. Boolean        rpc_SanityCheck = TRUE;
  34.  
  35.  
  36.  
  37. /*
  38.  *----------------------------------------------------------------------
  39.  *
  40.  * Test_RpcStub --
  41.  *
  42.  *    System call stub for the Rpc testing hook.  This is used
  43.  *    to do ECHO and SEND rpcs.
  44.  *
  45.  * Results:
  46.  *    An error code from the RPC.
  47.  *
  48.  * Side effects:
  49.  *    None.
  50.  *
  51.  *----------------------------------------------------------------------
  52.  */
  53.  
  54. ReturnStatus
  55. Test_RpcStub(command, argPtr)
  56.     int command;
  57.     Address argPtr;
  58. {
  59.     int inSize;
  60.     int outSize;
  61.     int argSize;
  62.     ReturnStatus status = SUCCESS;
  63.     
  64.     switch(command) {
  65.     case TEST_RPC_ECHO: {
  66.         Rpc_EchoArgs *echoArgsPtr = (Rpc_EchoArgs *)argPtr;
  67.         Time deltaTime;
  68.  
  69.         /*
  70.          * Make Accessible the struct containing the Echo arguments,
  71.          * then the in and out buffers.
  72.          */
  73.         Vm_MakeAccessible(VM_READONLY_ACCESS, sizeof(Rpc_EchoArgs),
  74.                (Address) echoArgsPtr, &argSize,
  75.                (Address *) (&echoArgsPtr));
  76.         if (echoArgsPtr == (Rpc_EchoArgs *)NIL) {
  77.         return(RPC_INVALID_ARG);
  78.         }
  79.         Vm_MakeAccessible(VM_READONLY_ACCESS,
  80.                   echoArgsPtr->size, echoArgsPtr->inDataPtr,
  81.                   &inSize, &echoArgsPtr->inDataPtr);
  82.         if (echoArgsPtr->inDataPtr == (Address)NIL) {
  83.         Vm_MakeUnaccessible((Address) echoArgsPtr, argSize);
  84.         return(RPC_INVALID_ARG);
  85.         }
  86.         Vm_MakeAccessible(VM_OVERWRITE_ACCESS,
  87.                   echoArgsPtr->size, echoArgsPtr->outDataPtr,
  88.                   &outSize, &echoArgsPtr->outDataPtr);
  89.         if (echoArgsPtr->outDataPtr == (Address)NIL) {
  90.         Vm_MakeUnaccessible(echoArgsPtr->inDataPtr, inSize);
  91.         Vm_MakeUnaccessible((Address) echoArgsPtr, argSize);
  92.         return(RPC_INVALID_ARG);
  93.         }
  94.         echoArgsPtr->size = (inSize > outSize) ? outSize : inSize ;
  95.  
  96.         status = Rpc_EchoTest(echoArgsPtr->serverID, echoArgsPtr->n,
  97.                 echoArgsPtr->size, echoArgsPtr->inDataPtr,
  98.                 echoArgsPtr->outDataPtr, &deltaTime);
  99.  
  100.         (void) Vm_CopyOut(sizeof(Time), (Address)&deltaTime,
  101.                      (Address)echoArgsPtr->deltaTimePtr);
  102.         Vm_MakeUnaccessible(echoArgsPtr->inDataPtr, inSize);
  103.         Vm_MakeUnaccessible(echoArgsPtr->outDataPtr, outSize);
  104.         Vm_MakeUnaccessible((Address) echoArgsPtr, argSize);
  105.         break;
  106.     }
  107.     case TEST_RPC_SEND: {
  108.         Rpc_EchoArgs *echoArgsPtr = (Rpc_EchoArgs *)argPtr;
  109.         Time deltaTime;
  110.  
  111.         Vm_MakeAccessible(VM_READONLY_ACCESS, sizeof(Rpc_EchoArgs),
  112.                (Address) echoArgsPtr, &argSize,
  113.                (Address *) (&echoArgsPtr));
  114.         if (argSize != sizeof(Rpc_EchoArgs)) {
  115.         return(RPC_INVALID_ARG);
  116.         }
  117.         Vm_MakeAccessible(VM_READONLY_ACCESS,
  118.                   echoArgsPtr->size, echoArgsPtr->inDataPtr,
  119.                   &inSize, &echoArgsPtr->inDataPtr);
  120.         if (echoArgsPtr->inDataPtr == (Address)NIL) {
  121.         Vm_MakeUnaccessible((Address) echoArgsPtr, argSize);
  122.         return(RPC_INVALID_ARG);
  123.         }
  124.  
  125.         status = Rpc_SendTest(echoArgsPtr->serverID, echoArgsPtr->n,
  126.                 inSize, echoArgsPtr->inDataPtr, &deltaTime);
  127.  
  128.         (void) Vm_CopyOut(sizeof(Time), (Address)&deltaTime,
  129.                      (Address)echoArgsPtr->deltaTimePtr);
  130.         Vm_MakeUnaccessible(echoArgsPtr->inDataPtr, inSize);
  131.         Vm_MakeUnaccessible((Address) echoArgsPtr, argSize);
  132.         break;
  133.     }
  134.     default:
  135.         status = RPC_INVALID_ARG;
  136.         break;
  137.     }
  138.     return(status);
  139. }
  140.  
  141.  
  142. /*
  143.  *----------------------------------------------------------------------
  144.  *
  145.  * Rpc_GetStats --
  146.  *
  147.  *    Copy out rpc system stats.
  148.  *
  149.  * Results:
  150.  *    SUCCESS, unless an argument could not be made accessible.
  151.  *
  152.  * Side effects:
  153.  *    Fill in the requested statistics.
  154.  *
  155.  *----------------------------------------------------------------------
  156.  */
  157. ReturnStatus
  158. Rpc_GetStats(command, option, argPtr)
  159.     int command;        /* Specifies what to do */
  160.     int option;            /* Modifier for command */
  161.     Address argPtr;        /* Argument for command */
  162. {
  163.     ReturnStatus status = SUCCESS;
  164.     
  165.     switch(command) {
  166.     case SYS_RPC_ENABLE_SERVICE: {
  167.         /*
  168.          * A basic On/Off switch for the RPC system.  Servers in
  169.          * particular want to get everything ready before responding
  170.          * to clients.
  171.          */
  172.         if (option) {
  173.         if (rpcSendNegAcks) {
  174.             RpcSetNackBufs();
  175.         }
  176.         printf("Starting RPC service\n");
  177.         rpcServiceEnabled = TRUE;
  178.         } else {
  179.         printf("Warning: Disabling RPC service\n");
  180.         rpcServiceEnabled = FALSE;
  181.         }
  182.         break;
  183.     }
  184.     case SYS_RPC_NUM_NACK_BUFS: {
  185.         /*
  186.          * Set the number of negative ack buffers.
  187.          */
  188.         if (rpcServiceEnabled) {
  189.         printf(
  190.             "Rpc service already enabled, cannot change nack bufs.\n");
  191.         break;
  192.         }
  193.         if (option > 0) {
  194.         printf("Setting number of nack bufs to %d\n", option);
  195.         rpc_NumNackBuffers = option;
  196.         RpcSetNackBufs();
  197.         }
  198.         break;
  199.     }
  200.     case SYS_RPC_SET_MAX: {
  201.         /*
  202.          * Set the maximum number of server procs allowed.  This can't
  203.          * go higher than the absolute maximum.
  204.          */
  205.         if (option <= 0) {
  206.         printf("Warning: asked to set max number of rpc server ");
  207.         printf("procs to %d.  I won't do this.\n", option);
  208.         } if (option < rpcNumServers) {
  209.         printf("Warning: asked to set max number of rpc server ");
  210.         printf("procs to %d which is less than the current ", option);
  211.         printf("number of procs: %d.\n", rpcNumServers);
  212.         printf("I can't do this.\n");
  213.         } else if (option > rpcAbsoluteMaxServers) {
  214.         printf("Warning: asked to set max number of rpc server ");
  215.         printf("procs to %d which is above the absolute ", option);
  216.         printf("maximum of %d.\n", rpcAbsoluteMaxServers);
  217.         printf("Setting this to maximum instead.\n");
  218.         rpcMaxServers = rpcAbsoluteMaxServers;
  219.         } else {
  220.         printf("Setting max number of server procs to %d.\n", option);
  221.         rpcMaxServers = option;
  222.         }
  223.         break;
  224.     }
  225.     case SYS_RPC_SET_NUM: {
  226.         /*
  227.          * Set the number of rpc processes to the given number, if
  228.          * there aren't already that many.
  229.          */
  230.         int    pid;
  231.  
  232.         if (option <= 0) {
  233.         printf("Warning: asked to set number of rpc server ");
  234.         printf("procs to %d.  I won't do this.\n", option);
  235.         } else if (option < rpcNumServers) {
  236.         printf("There are already %d server procs, ", rpcNumServers);
  237.         printf("and I won't kill them.\n");
  238.         } else if (option > rpcMaxServers) {
  239.         printf("Warning: asked to set number of rpc server ");
  240.         printf("procs to %d, which is above the maximum of %d\n",
  241.             option, rpcMaxServers);
  242.         printf("I'll create up to the maximum.\n");
  243.         while (rpcNumServers < rpcMaxServers) {
  244.             if (Rpc_CreateServer(&pid) == SUCCESS) {
  245.             printf("RPC srvr %x\n", pid);
  246.             RpcResetNoServers(0);
  247.             } else {
  248.             printf("Warning: no more RPC servers\n");
  249.             RpcResetNoServers(-1);
  250.             }
  251.         }
  252.         } else {
  253.         /* create the correct number */
  254.         while (rpcNumServers < option) {
  255.             if (Rpc_CreateServer(&pid) == SUCCESS) {
  256.             printf("RPC srvr %x\n", pid);
  257.             RpcResetNoServers(0);
  258.             } else {
  259.             printf("Warning: no more RPC servers\n");
  260.             RpcResetNoServers(-1);
  261.             }
  262.         }
  263.         }
  264.         break;
  265.     }
  266.     case SYS_RPC_NEG_ACKS: {
  267.         printf("Turning negative acknowledgements %s.\n",
  268.             option ? "on" : "off");
  269.         rpcSendNegAcks = option;
  270.         break;
  271.     }
  272.     case SYS_RPC_CHANNEL_NEG_ACKS: {
  273.         printf("Turning client policy of ramping down channels %s.\n",
  274.             option ? "on" : "off");
  275.         rpcChannelNegAcks = option;
  276.         break;
  277.     }
  278.     case SYS_RPC_CLT_STATS: {
  279.         register Rpc_CltStat *cltStatPtr;
  280.  
  281.         cltStatPtr = (Rpc_CltStat *)argPtr;
  282.         if (cltStatPtr == (Rpc_CltStat *)NIL ||
  283.         cltStatPtr == (Rpc_CltStat *)0 ||
  284.         cltStatPtr == (Rpc_CltStat *)USER_NIL) {
  285.         
  286.         Rpc_PrintCltStat();
  287.         } else {
  288.         RpcResetCltStat();
  289.         status = Vm_CopyOut(sizeof(Rpc_CltStat),
  290.                   (Address)&rpcTotalCltStat,
  291.                   (Address) cltStatPtr);
  292.         }
  293.         break;
  294.     }
  295.     case SYS_RPC_SRV_STATS: {
  296.         register Rpc_SrvStat *srvStatPtr;
  297.  
  298.         srvStatPtr = (Rpc_SrvStat *)argPtr;
  299.         if (srvStatPtr == (Rpc_SrvStat *)NIL ||
  300.         srvStatPtr == (Rpc_SrvStat *)0 ||
  301.         srvStatPtr == (Rpc_SrvStat *)USER_NIL) {
  302.         
  303.         Rpc_PrintSrvStat();
  304.         } else {
  305.         RpcResetSrvStat();
  306.         status = Vm_CopyOut(sizeof(Rpc_SrvStat),
  307.                   (Address)&rpcTotalSrvStat,
  308.                   (Address) srvStatPtr);
  309.         }
  310.         break;
  311.     }
  312.     case SYS_RPC_TRACE_STATS: {
  313.         switch(option) {
  314.         case SYS_RPC_TRACING_PRINT:
  315.             Rpc_PrintTrace((ClientData)32);
  316.             break;
  317.         case SYS_RPC_TRACING_ON:
  318.             rpc_Tracing = TRUE;
  319.             break;
  320.         case SYS_RPC_TRACING_OFF:
  321.             rpc_Tracing = FALSE;
  322.             break;
  323.         default:
  324.             /*
  325.              * The option is the size of the users buffer to
  326.              * hold all the trace records.
  327.              */
  328.             status = Trace_Dump(rpcTraceHdrPtr, RPC_TRACE_LEN, argPtr);
  329.             break;
  330.         }
  331.         break;
  332.     }
  333.     case SYS_RPC_SERVER_HIST: {
  334.         /*
  335.          * Operate on the service-time histograms, depending on option.
  336.          */
  337.         if (option > 0 && option <= RPC_LAST_COMMAND) {
  338.         /*
  339.          * Copy out the histogram for the service time of the RPC
  340.          * indicated by option.
  341.          */
  342.         status = Rpc_HistDump(rpcServiceTime[option], argPtr);
  343.         } else if (option > RPC_LAST_COMMAND) {
  344.         status = RPC_INVALID_ARG;
  345.         } else {
  346.         /*
  347.          * Reset all the server side histograms
  348.          */
  349.         status = SUCCESS;
  350.         for (option = 1 ; option <= RPC_LAST_COMMAND ; option++) {
  351.             Rpc_HistReset(rpcServiceTime[option]);
  352.         }
  353.         }
  354.         break;
  355.     }
  356.     case SYS_RPC_CLIENT_HIST: {
  357.         /*
  358.          * Operate on the client call-time histograms, depending on option.
  359.          */
  360.         if (option > 0 && option <= RPC_LAST_COMMAND) {
  361.         /*
  362.          * Copy out the histogram for the client's view of the service
  363.          * time of the RPC indicated by option.
  364.          */
  365.         status = Rpc_HistDump(rpcCallTime[option], argPtr);
  366.         } else if (option > RPC_LAST_COMMAND) {
  367.         status = RPC_INVALID_ARG;
  368.         } else {
  369.         /*
  370.          * Reset all the client side histograms
  371.          */
  372.         status = SUCCESS;
  373.         for (option = 1 ; option <= RPC_LAST_COMMAND ; option++) {
  374.             Rpc_HistReset(rpcCallTime[option]);
  375.         }
  376.         }
  377.         break;
  378.     }
  379.     case SYS_RPC_SRV_STATE: {
  380.         /*
  381.          * Return the state of the server processes.
  382.          */
  383.         if (option >= 0 && option < rpcNumServers) {
  384.         /*
  385.          * Copy out the state of the option'th server process.
  386.          */
  387.         status = Vm_CopyOut(sizeof(RpcServerState),
  388.                   (Address)rpcServerPtrPtr[option], argPtr);
  389.         } else {
  390.         status = RPC_INVALID_ARG;
  391.         }
  392.         break;
  393.     }
  394.     case SYS_RPC_CLT_STATE: {
  395.         /*
  396.          * Return the state of the client channels.
  397.          */
  398.         if (option >= 0 && option < rpcNumChannels) {
  399.         /*
  400.          * Copy out the state of the option'th client channel.
  401.          */
  402.         status = Vm_CopyOut(sizeof(RpcClientChannel),
  403.                   (Address)rpcChannelPtrPtr[option], argPtr);
  404.         } else {
  405.         status = RPC_INVALID_ARG;
  406.         }
  407.         break;
  408.     }
  409.     case SYS_RPC_CALL_COUNTS: {
  410.         register int *callCountPtr;
  411.  
  412.         callCountPtr = (int *)argPtr;
  413.         if (callCountPtr == (int *)NIL ||
  414.         callCountPtr == (int *)0 ||
  415.         callCountPtr == (int *)USER_NIL ||
  416.         option <= 0) {
  417.         
  418.         Rpc_PrintCallCount();
  419.         } else {
  420.         status = Vm_CopyOut(option,
  421.                   (Address) rpcClientCalls,
  422.                   (Address) callCountPtr);
  423.         }
  424.         break;
  425.     }
  426.     case SYS_RPC_SRV_COUNTS: {
  427.         register int *serviceCountPtr;
  428.  
  429.         serviceCountPtr = (int *)argPtr;
  430.         if (serviceCountPtr == (int *)NIL ||
  431.         serviceCountPtr == (int *)0 ||
  432.         serviceCountPtr == (int *)USER_NIL ||
  433.         option <= 0) {
  434.         
  435.         Rpc_PrintServiceCount();
  436.         } else {
  437.         status = Vm_CopyOut(option,
  438.                   (Address) rpcServiceCount,
  439.                   (Address) serviceCountPtr);
  440.         }
  441.         break;
  442.     }
  443.     case SYS_RPC_SANITY_CHECK: {
  444.         printf("Turning RPC sanity checking %s, was %s.\n",
  445.             option ? "on" : "off",
  446.             rpc_SanityCheck ? "on" : "off");
  447.         rpc_SanityCheck = option;
  448.         break;
  449.     }
  450.     default:
  451.         status = RPC_INVALID_ARG;
  452.         break;
  453.     }
  454.     return(status);
  455. }
  456.  
  457. #if 0
  458. /*
  459.  * List of the minimum allowable size for the parameter area of Rpc
  460.  * requests. 
  461.  */
  462. static int rpcSanityParamSize[RPC_NUM_COMMANDS] = {
  463.    {0,                     /* RPC_BAD_COMMAND */
  464.     0,                     /* RPC_ECHO_1 */
  465.     0,                    /* RPC_ECHO_2 */
  466.     0,                     /* RPC_SEND */
  467.     0,                     /* RPC_RECEIVE */
  468.     0,                    /* RPC_GETTIME */
  469.     0,                      /* RPC_FS_PREFIX */
  470.     sizeof(Fs_OpenArgs),         /* RPC_FS_OPEN */
  471.     sizeof(FsrmtIOParam),         /* RPC_FS_READ */
  472.     sizeof(FsrmtIOParam),         /* RPC_FS_WRITE */
  473.     sizeof(FsRemoteCloseParams),    /* RPC_FS_CLOSE */
  474.     sizeof(Fs_LookupArgs),         /* RPC_FS_UNLINK */
  475.     sizeof(Fs_2PathParams),        /* RPC_FS_RENAME */
  476.     sizeof(Fs_OpenArgs),        /* RPC_FS_MKDIR */
  477.     sizeof(Fs_LookupArgs),        /* RPC_FS_RMDIR */
  478.     sizeof(Fs_MakeDeviceArgs),        /* RPC_FS_MKDEV */
  479.     sizeof(Fs_2PathParams),        /* RPC_FS_LINK */
  480.     0,                    /* RPC_FS_SYM_LINK */
  481.     sizeof(Fs_FileID),             /* RPC_FS_GET_ATTR */
  482.     sizeof(FsRemoteSetAttrParams),     /* RPC_FS_SET_ATTR */
  483.     sizeof(Fs_OpenArgs),        /* RPC_FS_GET_ATTR_PATH */
  484.     sizeof(Fs_SetAttrArgs),        /* RPC_FS_SET_ATTR_PATH */
  485.     sizeof(Fs_GetAttrResultsParam),     /* RPC_FS_GET_IO_ATTR */
  486.     sizeof(FsRemoteSetAttrParams),    /* RPC_FS_SET_IO_ATTR */
  487.     sizeof(FsDeviceRemoteOpenParam),    /* RPC_FS_DEV_OPEN */
  488.     sizeof(FsRemoteSelectParams),    /* RPC_FS_SELECT */
  489.     sizeof(FsrmtIOCParam),        /* RPC_FS_IO_CONTROL */
  490.     sizeof(ConsistMsg),            /* RPC_FS_CONSIST */
  491.     sizeof(ConsistReply),        /* RPC_FS_CONSIST_REPLY */
  492.     sizeof(FsrmtBlockCopyParam),    /* RPC_FS_COPY_BLOCK */
  493.     sizeof(FsMigInfo),            /* RPC_FS_MIGRATE */
  494.     sizeof(FsStreamReleaseParam),    /* RPC_FS_RELEASE */
  495.     sizeof(Fs_FileID),            /* RPC_FS_REOPEN */
  496.     sizeof(int),            /* RPC_FS_RECOVERY */
  497.     sizeof(Fs_FileID),            /* RPC_FS_DOMAIN_INFO */
  498.     sizeof(ProcMigCmd),            /* RPC_PROC_MIG_COMMAND */
  499.     0,                    /* RPC_PROC_REMOTE_CALL */
  500.     sizeof(ProcRemoteWaitCmd),        /* RPC_PROC_REMOTE_WAIT */
  501.     sizeof(int),            /* RPC_PROC_GETPCB */
  502.     sizeof(Sync_RemoteWaiter),        /* RPC_REMOTE_WAKEUP */
  503.     sizeof(SigParms),            /* RPC_SIG_SEND */
  504.     sizeof(FsStreamReleaseParam),     /* RPC_FS_RELEASE_NEW */
  505. };
  506. #endif
  507.  
  508.  
  509. /*
  510.  *----------------------------------------------------------------------
  511.  *
  512.  * Rpc_SanityCheck --
  513.  *
  514.  *    Do some sanity checks on the packet.  This is not meant to be
  515.  *    an exhaustive test of the validity of a packet; rather it
  516.  *    is intended to be a debugging aid for weeding out bad packets
  517.  *    from clients.
  518.  *
  519.  * Results:
  520.  *    SUCCESS if the packet looks ok, FAILURE otherwise
  521.  *
  522.  * Side effects:
  523.  *    None.
  524.  *
  525.  *----------------------------------------------------------------------
  526.  */
  527.  
  528. ReturnStatus
  529. Rpc_SanityCheck(length, scatterPtr, packetLength)
  530.     int            length;        /* Length of the scatter/gather 
  531.                      * array. */    
  532.     Net_ScatterGather    *scatterPtr;     /* The scatter/gather array. */
  533.     int            packetLength;    /* Length of the network packet. */
  534.  
  535. {
  536.     static int        buffer[(RPC_MAX_SIZE + sizeof(RpcHdr)) / sizeof(int)];
  537.     RpcHdr        *rpcHdrPtr = NULL;
  538.     int            rpcLength;
  539.     ReturnStatus    status = SUCCESS;
  540.     char        *packetPtr;
  541.     int            paramSize;
  542.     int            dataSize;
  543.  
  544.     if (packetLength < sizeof(RpcHdr)) {
  545.     printf("RpcSanityCheck: packet smaller than an RpcHdr (%d)\n",
  546.         packetLength);
  547.     return FAILURE;
  548.     }
  549.     if (length == 1) {
  550.     rpcHdrPtr = (RpcHdr *) scatterPtr->bufAddr;
  551.     packetPtr = (char *) scatterPtr->bufAddr;
  552.     } else {
  553.     Net_GatherCopy(scatterPtr, length, 
  554.         (Address) buffer);
  555.     rpcHdrPtr = (RpcHdr *) buffer;
  556.     packetPtr = (char *) buffer;
  557.     }
  558.     if ((int) rpcHdrPtr & 0x3) {
  559.     printf("rpcHdrPtr = 0x%x\n", rpcHdrPtr);
  560.     rpc_SanityCheck = FALSE;
  561.     panic("Bye\n");
  562.     }
  563.     rpcLength = sizeof(RpcHdr) + rpcHdrPtr->paramSize + rpcHdrPtr->dataSize;
  564.     if (rpcLength > packetLength) {
  565.     printf("RpcSanityCheck: packet too short, %d < %d\n", 
  566.         packetLength, rpcLength);
  567.     status = FAILURE;
  568.     goto done;
  569.     }
  570.     /*
  571.      * We only deal with the first fragment of an RPC.
  572.      */
  573.  
  574.     if ((rpcHdrPtr->numFrags != 0) && (rpcHdrPtr->fragMask != 0x1)) {
  575.     return SUCCESS;
  576.     }
  577.     paramSize = rpcHdrPtr->paramSize;
  578.     dataSize = rpcHdrPtr->dataSize;
  579.     if (rpcHdrPtr->flags & RPC_REQUEST) {
  580.     switch(rpcHdrPtr->command) {
  581.         case RPC_FS_OPEN:
  582.         case RPC_FS_READ:
  583.         case RPC_FS_WRITE:
  584.         case RPC_FS_CLOSE:
  585.         case RPC_FS_UNLINK:
  586.         case RPC_FS_MKDIR:
  587.         case RPC_FS_RMDIR:
  588.         case RPC_FS_MKDEV:
  589.         case RPC_FS_GET_ATTR:
  590.         case RPC_FS_SET_ATTR:
  591.         case RPC_FS_GET_ATTR_PATH:
  592.         case RPC_FS_SET_ATTR_PATH:
  593.         case RPC_FS_SET_IO_ATTR:
  594.         case RPC_FS_DEV_OPEN:
  595.         case RPC_FS_SELECT: 
  596.         case RPC_FS_IO_CONTROL:
  597.         case RPC_FS_CONSIST:
  598.         case RPC_FS_CONSIST_REPLY:
  599.         case RPC_FS_COPY_BLOCK:
  600.         case RPC_FS_MIGRATE:
  601.         case RPC_FS_RELEASE:
  602.         case RPC_FS_REOPEN:
  603.         case RPC_FS_DOMAIN_INFO: {
  604.         Fs_FileID    *fileIDPtr;
  605.         if (paramSize < sizeof(Fs_FileID)) {
  606.             printf("Rpc_SanityCheck: request %d param too small (%d)\n",
  607.             paramSize);
  608.             status = FAILURE;
  609.             break;
  610.         }
  611.         fileIDPtr = (Fs_FileID *) (packetPtr + sizeof(RpcHdr));
  612.         if ((int) packetPtr & 0x3) {
  613.             printf("packetPtr = 0x%x\n", packetPtr);
  614.             panic("Bye\n");
  615.         }
  616.         if ((fileIDPtr->type < 0) || 
  617.             (fileIDPtr->type >= FSIO_NUM_STREAM_TYPES)) {
  618.             printf("Rpc_SanityCheck: request %d file id type = %d\n", 
  619.             rpcHdrPtr->command, fileIDPtr->type);
  620.             status = FAILURE;
  621.         }
  622.         break;
  623.         }
  624.     }
  625.     }
  626. done:
  627.     if (status != SUCCESS) {
  628.     printf("Rpc_SanityCheck: client %d, server %d:\n", 
  629.         rpcHdrPtr->clientID, rpcHdrPtr->serverID);
  630.     }
  631.     return status;
  632. }
  633.  
  634.  
  635.